package Part02.SPELDI;

/**
 * Created by futao on 2017/10/11.
 */
public class Person {
    /**
     * 姓名
     */
    private String pname;
    /**
     * 年龄
     */
    private int page;

    /**
     * 带参构造方法
     *
     * @param pname 姓名
     * @param page  年龄
     */
    public Person(String pname, int page) {
        this.pname = pname;
        this.page = page;
    }

    public Person() {
    }

    public String getPname() {
        return pname;
    }

    public void setPname(String pname) {
        this.pname = pname;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    @Override
    public String toString() {
        return "Person{" +
                "pname='" + pname + '\'' +
                ", page=" + page +
                '}';
    }

    /**
     * 控制年龄
     *
     * @return
     */
    public int calculateAge() {
        return page > 25 ? 25 : page;
    }
}
